using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;

namespace OrganizationStructureTree.Models
{
    public class OrganizationStructureTreeContext : DbContext
    {
        public DbSet<User> User { get; set; }
        public DbSet<Tree> Tree { get; set; }
        public DbSet<Node> Node { get; set; }
        public DbSet<UserNode> UserNode { get; set; }
        public DbSet<RootNode> RootNode { get; set; }
        public DbSet<DepartmentNode> DepartmentNode { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

            modelBuilder.Entity<Node>()
                        .Map(m => m.ToTable("Nodes"))
                        .Map<UserNode>(m => m.ToTable("UserNodes"))
                        .Map<DepartmentNode>(m => m.ToTable("DepartmentNodes"))
                        .Map<RootNode>(m => m.ToTable("RootNodes"));
        }
    }
}